﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Script.Services;
using System.Web.Services;
using MS.InformationManagement.BLL.DocumentScheduler;
using MS.InformationManagement.DAL.DTOs;
using MS.InformationManagement.Support;
using MS.InformationManagement.Support.Constants;
using MS.InformationManagement.Core.Support;
using Microsoft.SharePoint;

namespace MS.InformationManagement.Services
{
    /// <summary>
    /// Summary description for DocumentSchedulerService
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    [ScriptService]
    public class RibbonMethods : System.Web.Services.WebService
    {
        [WebMethod]
        public string[] GetItemsContentType(int[] selectedIds, string listIds)
        {
            try
            {
                return DocumentSetHelper.getItemContentType(selectedIds, listIds);
            }
            catch (Exception ex)
            {
                //Logger.LogException(ex, Microsoft.SharePoint.Administration.EventSeverity.Error,
                //    SPDiagnosticsAreas.SHAREPOINTFOUNDATION, SPDiagnosticsAreas.SharepointFoundationDiagnosticsCategories.WEBPARTS);
                throw;
            }
        }

        [WebMethod]
        public bool IsAnyDocumentScheduled(int[] selectedIds, string listId)
        {
            try
            { 
                return DocumentSchedulerBLL.IsAnyDocumentScheduled(selectedIds, new Guid(listId));
            }
            catch (Exception ex)
            {
                Logger.LogException(ex, Microsoft.SharePoint.Administration.EventSeverity.Error,
                    SPDiagnosticsAreas.SHAREPOINTFOUNDATION, SPDiagnosticsAreas.SharepointFoundationDiagnosticsCategories.WEBPARTS);
                throw;
            }
        }

        [WebMethod]
        public bool PuedoAnular(int[] selectedIds, string listId)
        {
            try
            {
                return MS.InformationManagement.BLL.SolicitudAnulacion.SolicitudAnulacion.PuedoAnular(selectedIds[0], new Guid(listId));
            }
            catch (Exception ex)
            {
                //Logger.LogException(ex, Microsoft.SharePoint.Administration.EventSeverity.Error,
                //    SPDiagnosticsAreas.SHAREPOINTFOUNDATION, SPDiagnosticsAreas.SharepointFoundationDiagnosticsCategories.WEBPARTS);
                throw;
            }
        }

    }
}
